<template>
  <div>
    <el-table :data="tableData" style="width: 100%">
      <!-- <el-table-column type="expand">
        <template slot-scope="props">
          <el-form inline label-position="left" class="demo-table-expand">
            <el-form-item>
              <el-upload
                class="upload-demo"
                drag
                action="https://jsonplaceholder.typicode.com/posts/"
                multiple
              >
                <i class="el-icon-upload"></i>
                <div class="el-upload__text">
                  将文件拖到此处，或
                  <em>点击上传</em>
                </div>
                <div class="el-upload__tip" slot="tip">只能上传jpg/png文件，且不超过500kb</div>
              </el-upload>
              <div style="margin-left:30px;margin-right:365px;">
                <div style="margin-bottom:97px;display:flex">
                  <span class="itemtit">注册时间</span>
                  <span class="itemtext">{{ props.row.add_time }}</span>
                </div>
                <div style="display:flex">
                  <span class="itemtit">地区</span>
                  <span class="itemtext"></span>
                </div>
              </div>
              <div>
                <div style="margin-bottom:97px;display:flex">
                  <span class="itemtit">性别</span>
                  <span class="itemtext" v-if="props.row.sex==1">保密</span>
                  <span class="itemtext" v-if="props.row.sex==2">男</span>
                  <span class="itemtext" v-if="props.row.sex==3">女</span>
                </div>
                <div style="display:flex">
                  <span class="itemtit">生日</span>
                  <span class="itemtext">{{ props.row.birthday }}</span>
                </div>
              </div>
            </el-form-item>
          </el-form>
        </template>
      </el-table-column> -->
      <el-table-column label="姓名" prop="nickname" label-class-name="colname" class-name="clos">
        <template slot-scope="scope">
          <el-button type="text" @click="godetail(scope.row)">{{scope.row.nickname}}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="手机号" prop="phone" label-class-name="colname"></el-table-column>
      <el-table-column label="状态" prop="status" label-class-name="colname">
        <template slot-scope="scope">
          <span v-if="scope.row.status==1">未激活</span>
          <span v-if="scope.row.status==2">已激活</span>
        </template>
      </el-table-column>
      <el-table-column label="上次预约时间" prop="add_time" label-class-name="colname"></el-table-column>

      <!-- <el-table-column label="有效储值" sortable prop="effective" label-class-name="colname"></el-table-column> -->
      <!-- <el-table-column label="赠送储值" sortable prop="giving" label-class-name="colname"></el-table-column> -->
      <!-- <el-table-column label="门店" prop="store_name" label-class-name="colname">
        <template slot-scope="scope">
          <el-button size="mini">{{scope.row.store_name}}</el-button>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="激活" prop="status" label-class-name="colname">
        <template slot-scope="scope">
          <el-switch
                  v-model="scope.row.check"
                  @change="handleLock(scope.row)"
                  active-color="#409EFF"
                  inactive-color="#DCDFE6"
                ></el-switch>
        </template>
      </el-table-column> -->
      <el-table-column label="操作">
        <template slot-scope="scope">
          <!-- <el-button type="text" @click="addappointment(scope.row)">添加预约</el-button> -->
          <el-button
            type="text"
            v-if="user_5"
            @click="handleEdit(scope.row)"
          >编辑</el-button>
          <el-button
            type="text"
            v-if="user_9"
            @click="handleDel(scope.row)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
       <div style="width:100%;text-align:center;margin:50px auto;">
          <el-pagination
            background
            :page-size="10"
            :page-sizes="[10, 20, 50, 100]"
             layout="total,prev, sizes, pager, next, jumper"
              :total="totle"
              @size-change="handleSizeChange"
            @current-change="fenyeBtn"
          ></el-pagination>
        </div>
    <el-dialog title="编辑用户" :visible.sync="dialogVisible" width="50%">
      <el-form
        ref="formInfo"
        :rules="rules"
        :model="formInfo"
        class="demo-form-inline"
        label-width="100px"
      >
        <el-form-item label="客户名称" prop="nickname">
          <el-input v-model="formInfo.nickname" />
        </el-form-item>
        <el-form-item label="客户手机" prop="phone">
          <!-- <el-input v-model.number="formInfo.code" type="number" onkeypress="return (/[\d]/.test(String.fromCharCode(event.keyCode)))" /> -->
          <el-input v-model.number="formInfo.phone" />
        </el-form-item>
        <el-form-item label="客户类别" prop="type">
          <el-select style="width:50%" v-model="formInfo.type" clearable placeholder="请选择客户类别">
            <el-option
              v-for="item in type"
              :key="item.userId"
              :label="item.value"
              :value="item.userId"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="客户性别" prop="sex">
          <el-select style="width:50%" v-model="formInfo.sex" clearable placeholder="请选择客户性别">
            <el-option
              v-for="item in sex"
              :key="item.userId"
              :label="item.value"
              :value="item.userId"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="生日" prop="birthday">
          <!-- <el-input style="width:220px;" v-model="formInfo.birthday" placeholder="选择日期" /> -->
           <!-- <el-col :span="6"> -->
          <el-date-picker style="width:50%" v-model="formInfo.birthday" type="date" placeholder="选择日期"></el-date-picker>
          <!-- </el-col> -->
          <!-- <el-date-picker
            v-model="formInfo.birthday"
            align="right"
            type="date"
            placeholder="选择日期"
            :picker-options="pickerOptions"
          ></el-date-picker> -->
        </el-form-item>
        <el-form-item label="学习目标" prop="target_id">
          <el-select style="width:50%" v-model="formInfo.target_id" clearable placeholder="请选择">
            <el-option
              v-for="item in addData.target"
              :key="item.id"
              :label="item.title"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="学习内容" prop="content_id">
          <el-select style="width:50%" v-model="formInfo.content_id" clearable placeholder="请选择">
            <el-option
              v-for="item in addData.content"
              :key="item.id"
              :label="item.title"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="学习时长" prop="length_id">
          <el-select style="width:50%" v-model="formInfo.length_id" clearable placeholder="请选择">
            <el-option
              v-for="item in addData.duration"
              :key="item.id"
              :label="item.title"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="路程花费" prop="cost_id">
          <el-select style="width:50%" v-model="formInfo.cost_id" clearable placeholder="请选择">
            <el-option
              v-for="item in addData.cost"
              :key="item.id"
              :label="item.title"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="来源渠道" prop="channel_id">
          <el-select style="width:50%" v-model="formInfo.channel_id" clearable placeholder="请选择">
            <el-option
              v-for="item in addData.channel"
              :key="item.id"
              :label="item.title"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item style="text-align: right;">
          <el-button @click="closeDialog()">取消</el-button>
          <el-button type="primary" @click="submitForm('formInfo')">确定</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-dialog title="添加预约" @close="handleClosed" :visible.sync="appointment" width="50%">
      <el-form
        ref="formappointment"
        :rules="rules"
        :model="formappointment"
        class="demo-form-inline"
        label-width="100px"
      >
        <el-form-item label="预约店铺" prop="store_shop">
          <!-- <el-input v-model="formappointment.shop" disabled></el-input> -->
          <!-- <el-col :span="6"> -->
            <el-select v-model="formappointment.store_shop" style="width:50%" @change="changestores" placeholder="请选择">
              <el-option
                v-for="item in storelist"
                :key="item.id"
                :label="item.store_name"
                :value="item.id"
              ></el-option>
            </el-select>
          <!-- </el-col> -->
        </el-form-item>
        <el-form-item label="预约日期" prop="date">
          <!-- <el-input v-model="formappointment.date" placeholder="请选择"></el-input> -->
          <!-- <el-col :span="6"> -->
            <el-date-picker
             style="width:50%"
              :picker-options="pickerOptions"
              value-format="yyyy-MM-dd"
              v-model="formappointment.date"
              @change="changestartdata"
              type="date"
              placeholder="选择日期"
            ></el-date-picker>
          <!-- </el-col> -->
        </el-form-item>
        <el-form-item label="预约开始" prop="appointmentstart">
          <!-- <el-input v-model="formappointment.appointmentstart" placeholder="请选择"></el-input> -->
          <el-time-select
            placeholder="选择时间"
            style="width:50%;"
            v-model="formappointment.appointmentstart"
            @change="changestartappo"
            :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '24:00',
                      maxTime: formappointment.appointmentend
                    }"
          ></el-time-select>
        </el-form-item>
        <!-- <el-form-item label="结束日期" prop="enddate">
            <el-date-picker
             style="width:50%"
              :picker-options="pickerOptions"
              value-format="yyyy-MM-dd"
              v-model="formappointment.enddate"
              @change="changeenddata"
              type="date"
              placeholder="选择日期"
            ></el-date-picker>
        </el-form-item> -->
        <el-form-item label="预约结束" prop="appointmentend">
          <el-time-select
            placeholder="选择时间"
            style="width:50%;"
            v-model="formappointment.appointmentend"
            @change="changeendappo"
            :picker-options="{
                      start: '00:00',
                      step: '00:30',
                      end: '24:00',
                      minTime: formappointment.appointmentstart
                    }"
          ></el-time-select>
        </el-form-item>
        <el-form-item label="预约座位" v-if="isshop" prop="reservedseats">
          <div v-for="(item,index) in seatlist" :key="index" style="margin-bottom:20px;">
            <div style="display:flex;">{{item.title}}</div>
            <!--  -->
            <div style="display:flex;flex-wrap:wrap;">
              <div
                v-for="(items,indexs) in item.seat"
                :key="indexs"
                @click="ckeckdatas(items,item)"
                :class="isActiveFn(items)?'active':items.check==false?'itemcont':'itemconts'"
              >
                {{items.seat_name}}
                <img
                  src="../../../assets/img/duihao.png"
                  v-if="items.id==currentindex"
                  style="width:26px;height:24px;position: absolute;"
                  alt
                />
              </div>
            </div>
          </div>
        </el-form-item>
        <el-form-item label="选择套餐" prop="selectpackage">
          <el-select
            style="width:50%"
            v-model="formappointment.selectpackage"
            @change="mealchage($event,Meallists)"
            placeholder="请选择"
          >
            <el-option
              v-for="item in Meallists"
              :key="item.id"
              :label="item.setname"
              :value="item.id"
            />
            <!-- <el-pagination
              small
              layout="prev, pager, next"
              hide-on-single-page
              :total="totle2s"
              @current-change="fenyeBtn2s"
            ></el-pagination> -->
          </el-select>
        </el-form-item>
        <div v-if="isdaynum">
           <el-radio-group v-model="radio1" @change="radiochang">

          <div class="flexwap" v-for="(item,index) in daynumlist" :key="index">
          <el-form-item label="天数">
            <el-input disabled v-model="item.day">
              <template slot="append">天</template>
            </el-input>
          </el-form-item>
          <el-form-item label="价格">
            <el-input disabled v-model="item.price">
              <template slot="append">元</template>
            </el-input>
          </el-form-item>
            <!-- <el-radio :label="1">备选项</el-radio>
            <el-radio :label="2">备选项</el-radio>
            <el-radio :label="3">备选项</el-radio> -->
           <el-radio style="margin-left:20px" :label="item.set_day_id" border>选择此套餐</el-radio>
        </div>
          </el-radio-group>
        </div>
        <el-form-item label="备注" prop="remarks">
          <el-input v-model="formappointment.remarks"></el-input>
        </el-form-item>
        <el-form-item style="text-align: right;">
          <el-button @click="resetForm('formappointment')">重置</el-button>
          <el-button type="primary" @click="appointmentsubmitForm('formappointment')">确定</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <!-- <el-dialog title="固定座位用户" :visible.sync="lockpopup" width="50%">
      <el-table :data="userData" border style="width: 100%">
        <el-table-column prop="name" label="姓名"></el-table-column>
        <el-table-column prop="phone" label="手机"></el-table-column>
        <el-table-column prop="details" label="详情" width="550">
          <template slot-scope="scope">
            <div style="display:flex;flex-wrap:nowrap">
              <span style="margin-right:80px;">{{scope.row.date}}</span>
              <span style="margin-right:80px;">{{scope.row.time}}</span>
              <span style="margin-right:80px;">{{scope.row.ord}}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="store" label="门店"></el-table-column>
      </el-table>
    </el-dialog>-->
  </div>
</template>

<script>
var moment = require('moment');
import {
  getUserList,
  highest,
  Addcontent,
  userInfoEdit,
  userStatus,
  lists,
  appointReturn,
  userdelete,
  appointmentAdd,
  // choice,
  packageReturn
  // packages
} from "@/api/user";
import { adminStore } from "@/api/menu";
import Base64 from "@/utils/base";
import { getp_id } from "@/utils/getmenuid";
export default {
  data() {
    return {
      storelist: "",
      seatlist: "",
      totle:10,
      page:1,
      num:10,
      user_5:false,
      user_6:false,
      user_9:false,
      radio1:"",
      typeid:"",
      isdaynum: false,
      daynumlist:"",
      pickerOptions: {
        disabledDate(date) {
          return date.getTime() < Date.now() - 24 * 60 * 60 * 1000;
        }
      },
      userData: [
        {
          name: "lucky",
          phone: "15828947596",
          details: "",
          date: "12.23—01.01",
          time: "00:00—23:59",
          ord: "c-5",
          store: "莲花北店"
        }
      ],
      lockpopup: false,
      datevalue: "",
      formInfo: "",
      value: "",
      userid:"",
      genid:"",
      dialogVisible: false,
      type: [
        {
          userId: 1,
          value: "微信用户"
        },
        {
          userId: 2,
          value: "普通会员"
        },
        {
          userId: 3,
          value: "会员"
        }
      ],
      sex: [
        {
          userId: 1,
          value: "保密"
        },
        {
          userId: 2,
          value: "女"
        },
        {
          userId: 3,
          value: "男"
        }
      ],
      objectives: [
        {
          userId: 0,
          value: "暂无"
        },
        {
          userId: 1,
          value: "年级前十"
        }
      ],
      content: [
        {
          userId: 0,
          value: "暂无"
        },
        {
          userId: 1,
          value: "凌晨4点"
        }
      ],
      time: [
        {
          userId: 0,
          value: "2小时"
        },
        {
          userId: 1,
          value: "1小时"
        }
      ],
      price: [
        {
          userId: 0,
          value: "100"
        },
        {
          userId: 1,
          value: "120"
        }
      ],
      channel: [
        {
          userId: 0,
          value: "抖音"
        },
        {
          userId: 1,
          value: "小红书"
        }
      ],
      rules: {
        nickname: [
          { required: true, message: "请输入客户名称", trigger: "change" }
        ],
        phone: [
          { required: true, message: "请输入客户手机", trigger: "change" }
        ],
        url: [{ required: true, message: "请输入菜单地址", trigger: "change" }],
        actionUppper: [
          { required: true, message: "请输入path路径", trigger: "change" }
        ],
        actionLower: [
          { required: true, message: "请输入name名称", trigger: "change" }
        ],
        code: [
          { required: true, message: "请输入code名称", trigger: "change" }
        ],
        hidden: [{ required: true, message: "请选择", trigger: "change" }],
        sort: [
          { required: true, message: "请选择排序方式", trigger: "change" }
        ],
        status: [
          { required: true, message: "请选择菜单状态", trigger: "change" }
        ]
      },
      currentindex: -1,
      serialid:"",
      rules: {
        num: [
          {
            required: true,
            message: "请输入购买数量",
            trigger: "change"
          }
        ],
        alltimes: [
          { required: true, message: "请输入总次数", trigger: "change" }
        ],
        usertimes: [
          { required: true, message: "请输入使用次数", trigger: "change" }
        ],
        value1: [
          { required: true, message: "请选择有效期", trigger: "change" }
        ],
        date: [
          { required: true, message: "请输入预约日期", trigger: "change" }
        ],
        appointmentstart: [
          { required: true, message: "请选择预约开始时间", trigger: "change" }
        ],
        appointmentend: [
          { required: true, message: "请选择预约结束时间", trigger: "change" }
        ],
        store_shop: [
          { required: true, message: "请选择预约店铺", trigger: "change" }
        ],
        // selectpackage: [
        //   { required: true, message: "请选择套餐", trigger: "change" }
        // ],
        // enddate: [
        //   { required: true, message: "请选择结束日期", trigger: "change" }
        // ],
        delpoint: [
          { required: true, message: "请输入扣减点", trigger: "change" }
        ],
        point: [{ required: true, message: "请输入充值点", trigger: "change" }],
        time: [{ required: true, message: "请输入时间", trigger: "change" }],
        shop: [
          { required: true, message: "请输入扣减店铺", trigger: "change" }
        ],
        // mealchoose: [
        //   { required: true, message: "请选择套餐", trigger: "change" }
        // ]
      },
      tableData: "",
      addData: "",
      Meallists: "",
      locks: "",
      isshop:false,
      itemlist: [],
      appointment:false,
      formappointment: {
        store_shop: "",
        date: "",
        selectpackage: "",
        appointmentstart: "",
        // enddate: "",
        appointmentend: "",
        remarks: "",
        reservedseats: ""
      },
      totle2s: 10,
      page2s: 1,
      num2s: 10
    };
  },
  mounted(){
  setTimeout(() => {
      this.getinfo();
      this.getadddata();
      // this.getsetMeal();
    }, 500);
  },
  created() {
    this.getlists()
              this.storelist =
      JSON.parse(localStorage.getItem("storemenu"))[0].id != ""
        ? JSON.parse(localStorage.getItem("storemenu"))
        : this.getadminStore();
  
  },
  methods: {
    //获取套餐列表0.
    //   let parmes = {
    //     page: page || this.page2s,
    //     limit: num || this.num2s,
    //     user_id:this.getinfodata.id
    //   };
    //   packages({
    //     request_data: Base64.encode(JSON.stringify(parmes))
    //   }).then(res => {
    //     console.log(res);
    //     this.Meallist = res.result.data;
    //     this.totle2s = res.result.count;
    //   });
    // },
    //  fenyeBtn2s(e) {
    //   this.page2s = e;
    //   this.getsetMeal(this.page2s, this.num2s);
    // },
    //选择预约店铺
    changestores(e) {
      this.currentindex = -1
      this.genid = ""
      this.typeid = ""
      this.serialid = ""
      this.formappointment.selectpackage = ""
      this.isdaynum = false
      this.formappointment.store_shop = e;
      if (this.formappointment.store_shop != "") {
        this.itemlist.length = 0;
        this.getappointReturn();
        this.getpackageReturn(e);
      }
      // this.storeid = e;
    
    },
    getpackageReturn(e){
      packageReturn({
        request_data: Base64.encode(JSON.stringify({ store_id: e,user_id:this.userid }))
      }).then(res => {
        if(res.status==2){
          this.$message({
            message:res.message,
            type:'warning'
          })
          return
        }
        this.Meallists = res.result;
        if(res.status==1){
        this.isshop = true
        }
      })
    },
    handleClosed(){
      this.$refs.formappointment.resetFields()
    },
     //选择套餐
    mealchage(event, item) {
      let obj = {};
      obj = this.Meallists.find(item => {
        //model就是上面的数据源
        return item.id === event; //筛选出匹配数据
      });
      this.typeid = obj.type
      if (obj.type == 1) {
        this.isdaynum = true;
        this.daynumlist = obj.set
        this.radio1 = obj.set[0].set_day_id
      } else {
        this.isdaynum = false;
      }
      this.formappointment.selectpackage = event;
    },
    radiochang(e){
      this.radio1 = e
    },
    changestartdata(e) {
      this.formappointment.date = e
      this.getappointReturn()
    },
    // changeenddata(e) {
    //   this.formappointment.enddate = e;
    //   this.getappointReturn();
    // },
    changestartappo(e) {
      this.formappointment.appointmentstart = e;
      this.getappointReturn();
    },
    changeendappo(e) {
      this.formappointment.appointmentend = e;
      this.getappointReturn();
    },
    ckeckdatas(item,paritem) {
      this.genid = paritem.id
      if (item.check == true) {
        return false;
      }
      this.currentindex = item.id
      this.serialid = item.seat_name
      // let index = this.itemlist.findIndex(ele => {
      //   return ele === item;
      // });
      this.itemlist[0]=item.id
      // if (index != -1) {
      //   this.itemlist.splice(index, 1); //取消选中
      // } else {
      //   this.itemlist.push(item); //选中
      // }
    },
    resetForm(formappointment) {
      this.$refs[formappointment].resetFields();
      this.appointmentend = "";
      this.selectpackage = "";
      this.formappointment.date = "";
      // this.formappointment.enddate = "";
      this.formappointment.appointmentstart = "";
    },
    appointmentsubmitForm(formappointment) {
      // console.log(this.formappointment)
      // let newseatlist = [];
      // this.itemlist.map(v => {
      //   newseatlist.push(v.id);
      // });
      // if(newseatlist==undefined||newseatlist==""){
      //   newseatlist=""
      // }
      this.$refs[formappointment].validate(valid => {
        if (valid) {
          let parmes = {
            user_id: this.userid,
            store_id: this.formappointment.store_shop,
            seat_id: this.formappointment.selectpackage,
            sub_start: this.formappointment.date,
            start_sub: this.formappointment.appointmentstart,
            // sub_end: this.formappointment.enddate,
            end_sub: this.formappointment.appointmentend,
            serial: this.serialid,
            desc: this.formappointment.remarks,
            set_day_id:this.typeid==1?this.radio1:"",
            serial_id:this.itemlist.length!=0?this.itemlist[0]:"",
            gen_id:this.genid,
            type:1
          }
          appointmentAdd({
            request_data: Base64.encode(JSON.stringify(parmes))
          }).then(res => {
            if(res.status==2){
          this.$message({
            message:res.message,
            type:'warning'
          })
          return
        }
            if (res.status == 1) {
              this.appointment = false
              this.isshop = false
              this.currentindex = -1
              this.genid = ""
              this.typeid = ""
              this.serialid = ""
              this.formappointment.selectpackage = ""
              this.$refs[formappointment].resetFields()
              this.getinfo()
              this.$message({
                message: res.message,
                type: "success"
              })
            }
          });
        } else {
          return false;
        }
      });
    },
    isActiveFn(item) {
      // console.log(item.id)
      // console.log(this.itemlist)
      //判断元素是否选中
      //index如果不是-1，那就说明是被选中的
      // let index = this.itemlist.findIndex(ele => {
      //   console.log(ele.id)
      //   return ele.id === item.id;
      // });
      if (item.id == this.itemlist[0]) {
        return true;
      } else {
        return false;
      }
    },
    getappointReturn() {
      // console.log(this.formappointment)
      // return
      let parmes = {
        user_id: this.userid,
        store_id: this.formappointment.store_shop,
        start_time: this.formappointment.date,
        // end_time: this.formappointment.enddate,
        start_sub: this.formappointment.appointmentstart,
        end_sub: this.formappointment.appointmentend
      };
      appointReturn({
        request_data: Base64.encode(JSON.stringify(parmes))
      }).then(res => {
        if(res.status==2){
          this.$message({
            message:res.message,
            type:'warning'
          })
          return
        }
        this.seatlist = res.result;
        // return res.data;
      });
    },
    getadminStore() {
      adminStore({
        request_data: Base64.encode(JSON.stringify({ store_id: "" }))
      }).then(res => {
        if(res.status==2){
          this.$message({
            message:res.message,
            type:'warning'
          })
          return
        }
        this.storelist = res.data;
        return res.data;
      });
    },
     handleSizeChange(val) {
      this.num = val
      this.getinfo(this.page,this.num);
    },
    fenyeBtn(e){
      this.page = e;
      this.getinfo(this.page,this.num);
    },
    getlists(){
      lists({
        request_data: Base64.encode(JSON.stringify({ pid: getp_id() }))
      }).then(res => {
        if(res.status==2){
          this.$message({
            message:res.message,
            type:'warning'
          })
          return
        }
        let btnarr = [];
        res.result.map(v => {
          btnarr.push(v.class_mark);
        });
        btnarr.forEach(item => {
          if (item == "user_5") {
            this.user_5 = true;
          }
          if (item == "user_6") {
            this.user_6 = true;
          }
          if (item == "user_9") {
            this.user_9 = true;
          }
        })
      })
    },
    getinfo(page,num) {
      let parmes= {
        name: "",
        page: page||this.page,
        limit: num||this.num,
        label: ""
      }
      getUserList({
        request_data: Base64.encode(JSON.stringify(parmes))
      }).then(res => {
        if(res.status==2){
          this.$message({
            message:res.message,
            type:'warning'
          })
          return
        }
        if (JSON.parse(localStorage.getItem("searchData"))) {
          this.tableData = JSON.parse(localStorage.getItem("searchData"));
        } else {
          this.tableData = res.result.data
          this.totle = res.result.count
        }
      })
    },
    getadddata() {
      Addcontent().then(res => {
        this.addData = res.result;
      })
    },
    godetail(e) {
      localStorage.setItem("getpid",getp_id())
      this.$router.push({
                path: './userBasic',
                query: e
            })
    },
    addappointment(data){
      this.userid = data.id
      this.appointment = true
    },
    handleEdit(val) {
      this.dialogVisible = true;
      this.formInfo = JSON.parse(JSON.stringify(val));
      if((val.birthday).indexOf("-")=='-1'){
      this.$set(this.formInfo, 'birthday', moment(val.birthday*1000).format('YYYY-MM-DD'))
      }else{
      this.$set(this.formInfo, 'birthday', moment(val.birthday).format('YYYY-MM-DD'))
      }
    },
    handleLock(data) {
      // if (data.status == 1) {
      //   this.locks = 2;
      // } else {
      //   this.locks = 1;
      // }
      let parem = {
        id: data.id,
        status: this.locks
      };
      userStatus({
        request_data: Base64.encode(JSON.stringify(parem))
      }).then(res => {
        if(res.status==2){
          this.$message({
            message:res.message,
            type:'warning'
          })
          return
        }
        this.getinfo();
      })
    },
    handleDel(val){
      this.$confirm("确定删除此条数据吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          let parem = {
        id: val.id
      };
      userdelete({
        request_data: Base64.encode(JSON.stringify(parem))
      }).then(res => {
        if(res.status==2){
          this.$message({
            message:res.message,
            type:'warning'
          })
          return
        }
        this.getinfo();
         this.$message({
              type: "success",
              message: "删除成功!"
            });
      })
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消"
          });
        });
    },
    // 关闭操作
    closeDialog() {
      this.dialogVisible = false;
    },
    submitForm(formInfo) {
      this.$set(this.formInfo, 'birthday', moment(this.formInfo.birthday).format('YYYY-MM-DD'))
      // return
      this.$refs[formInfo].validate(valid => {
        if (valid) {
          let editdata = {
            id: this.formInfo.id,
            nickname: this.formInfo.nickname,
            phone: this.formInfo.phone,
            type: this.formInfo.type,
            sex: this.formInfo.sex,
            birthday: this.formInfo.birthday,
            target_id: this.formInfo.target_id,
            length: this.formInfo.length_id,
            cost: this.formInfo.cost_id,
            channel_id: this.formInfo.channel_id,
            content_id: this.formInfo.content_id
          };
          userInfoEdit({
            request_data: Base64.encode(JSON.stringify(editdata))
          }).then(res => {
            if(res.status==2){
          this.$message({
            message:res.message,
            type:'warning'
          })
          return
        }
            this.dialogVisible = false;
            localStorage.removeItem("searchData");
            this.getinfo();
          });
        } else {
          return false;
        }
      });
    }
  }
};
</script>

<style scoped>
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
.el-form--inline .el-form-item__content {
  display: flex;
}
.colname {
  color: #919191;
}
.clos {
  color: #409eff;
}
.itemtit {
  white-space: nowrap;
  margin-right: 66px;
  color: #afafaf;
  font-size: 14px;
  width: 100px;
}
.itemtext {
  white-space: nowrap;
  color: #333333;
  font-size: 14px;
}
.active {
  position: relative;
  width: 52px;
  height: 52px;
  background: #512cff;
  border-radius: 6px;
  color: #512cff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  margin-bottom: 8px;
}
.itemcont {
  width: 52px;
  height: 52px;
  background: #ffffff;
  border: 1px solid #512cff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  margin-bottom: 8px;
  color: #101010;
  font-size: 20px;
  cursor: pointer;
}
.itemconts {
  cursor: not-allowed;
  width: 52px;
  height: 52px;
  background: #ffffff;
  border: 1px solid #bbbbbb;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  margin-bottom: 8px;
  color: #b9b9b9;
  font-size: 20px;
}
.flexwap {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
}
</style>
